var vm = new Vue({
    el: '#app',
    data: {
        tableData: [],//表格当前页数据
        pagesize: 20,//默认每页数据量
        facilitator: {}, //当前选择行数据
        currentPage: 1,//当前页码
        start: 1, //查询的页码
        totalCount: '',//默认数据总数
        multipleSelection: [],//多选数组
        q:{//搜索条件
            sellerName:'',
            goodsCount:'',
            active:'',
            facilitatorName:'',
            userDistributionName:'',
            beginCreatetime:'',
            endCreatetime:''
        },
        sellerCount:'',
        activeCount:'',
        transactionAmount:'',
        purchaseAccount:'',
        facilitatorCount:'',
        userDistributionCount:''
    },
    created () {
        Vue.nextTick(()=>{
            //载入数据
            vm.loadData(vm.currentPage, vm.pagesize);
        });
    },
    methods: {
        //从后台获取数据
        loadData: function (page, limit) {
            vm.q.page=vm.currentPage
            vm.q.limit=vm.pagesize
            $.ajax({
                type: "POST",
                url: baseURL + "facilitator/facilitator/facilitatorStatisticVo",
                contentType: "application/json",
                data: JSON.stringify(vm.q),
                success: function(r){
                    if(r.code === 0){
                        vm.tableData = r.page.list
                        vm.totalCount = r.page.totalCount
                        vm.sellerCount=r.sellerCount
                        vm.activeCount=r.activeCount
                        vm.transactionAmount=r.transactionAmount
                        vm.purchaseAccount=r.purchaseAccount
                        vm.facilitatorCount=r.facilitatorCount
                        vm.userDistributionCount=r.userDistributionCount
                    }else{
                        alert(r.msg);
                    }
                }
            });
        },
        //多选响应
        handleSelectionChange: function(val) {
            vm.multipleSelection = val;
            console.log(vm.multipleSelection)
        },
        //点击行响应
        handleclick: function(row, event, column){
            vm.facilitator = JSON.parse(JSON.stringify(row));//深克隆
        },
        //搜索
        search: function(){
            vm.loadData(vm.start, vm.pagesize);
        },
        //重置
        rest() {
            Object.keys(vm.q).forEach(key=>vm.q[key]='');
            vm.loadData(vm.currentPage, vm.pagesize);
        },
        //每页显示数据量变更
        handleSizeChange: function(val) {
            vm.pagesize = val;
            vm.loadData(vm.currentPage, vm.pagesize);
        },
        //页码变更
        handleCurrentChange: function(val) {
            vm.currentPage = val;
            vm.loadData(vm.currentPage, vm.pagesize);
        },
    }
});
